﻿using BlogApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BlogApi.Services
{
    /// <summary>
    /// 用户仓储接口
    /// </summary>
    public interface IUserRepository
    {
        /// <summary>
        /// 按创建时间降序获取用户表所有数据
        /// </summary>
        /// <returns>List<User>的集合</returns>
        Task<IEnumerable<User>> GetUsersAsync();
        /// <summary>
        /// 按创建时间降序分页获取用户表数据
        /// </summary>
        /// <param name="pageSize">每页大小</param>
        /// <param name="pageIndex">页索引号</param>
        /// <returns>分过页后的List<User>的集合</returns>
        Task<IEnumerable<User>> GetUsersByPageAsync(int pageSize,int pageIndex);
        /// <summary>
        /// 按用户粉丝数降序分页获取用户表数据
        /// </summary>
        /// <param name="pageSize">每页大小</param>
        /// <param name="pageIndex">页索引号</param>
        /// <returns>分过页后的List<User>的集合</returns>
        Task<IEnumerable<User>> GetUsersByPageOrderByFanNumberAsync(int pageSize, int pageIndex);
        /// <summary>
        /// 获取单个用户信息
        /// </summary>
        /// <param name="userId">用户的ID</param>
        /// <returns>对应的User实体类</returns>
        Task<User> GetUserAsync(Guid userId);
        /// <summary>
        /// 根据邮箱获取单个用户
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        Task<User> GetUserAsync(string email);
        /// <summary>
        /// 根据邮箱和密码获取用户
        /// </summary>
        /// <returns></returns>
        Task<User> GetUserByEmailAndPasswordAsync(string email,string password);
        /// <summary>
        /// 新增一个用户
        /// </summary>
        /// <param name="user">要新增用户</param>
        void AddUser(User user);
        /// <summary>
        /// 更新一个用户信息
        /// </summary>
        /// <param name="user">要更新的用户</param>
        void UpdateUser(User user);
        /// <summary>
        /// 删除一个对应用户
        /// </summary>
        /// <param name="user">要删除的用户实体类</param>
        void DeleteUser(User user);
        /// <summary>
        /// 判断用户是否存在
        /// </summary>
        /// <param name="userId">用户的ID</param>
        /// <returns></returns>
        Task<bool> UserExistsAsync(Guid userId);
        /// <summary>
        /// 判断邮箱是否存在
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        Task<bool> EmailExistsAsync(string email);
        /// <summary>
        /// 把更改的内容更新到数据库
        /// </summary>
        /// <returns></returns>
        Task<bool> SaveAsync();
    }
}
